package Thread;

public class ThreadDemo21 {
    private static int count;
    public static void main(String[] args) throws InterruptedException {
        Object locker = new Object();
        Thread t = new Thread(()->{
            synchronized (locker){//对于可重入锁来说，内部会有两个信息：
                //1、当前这个锁是被那个线程持有的
                //2、加锁次数的计数器
                synchronized (locker) {//count++
                    for (int i = 0; i < 1000000; i++) {
                        count++;
                    }
                }//count--
                //其他逻辑
            }//在这个大括号真正解锁
        });
        t.start();
        t.join();
        System.out.println(count);
    }
}
